/*
 * networkedLocksTest.c
 *
 *  Created on: Jul 9, 2011
 *      Author: peckb1
 */

#include "syscall.h"

/* Takes in a char array and returns the length of the char array. */
int charCount(char* ch) {
    int count = 0;
    int i=0;
    while(ch[i] != '\n') {
        count++;
        i++;
    }
    return count+1;
}


int lockIdToFail = -1;

void AcquireLockFork() {
    LockAcquire(lockIdToFail);
}

void DestroyLockFork() {
    LockDestroy(lockIdToFail);
}

void ReleaseLockFork() {
    LockRelease(lockIdToFail);
}

void LockHappyCaseOne() {
    int lockId = CreateLock("First Lock", 10);

    LockAcquire(lockId);

    LockRelease(lockId);

    LockDestroy(lockId);

    lockIdToFail = lockId;

    Fork(&AcquireLockFork, "AcquireLockFork", 15);

    Fork(&ReleaseLockFork, "ReleaseLockFork", 15);

    Fork(&DestroyLockFork, "DestroyLockFork", 15);
}


int lockIdForMain = -1;
int main() {

    LockHappyCaseOne();

    Write("MV MAIN TEST END OK\n", sizeof("MV MAIN TEST END OK\n"), ConsoleOutput);

    Exit(0);
}
